<template>
  <TwoColumnsResizView>
    <template v-slot:left>
      <div>
        <el-input  v-model="inputdata" style="width: 240px"/>
        <el-button @click="fetchStreamData">获取数据</el-button>
      </div>
    </template>

    <template v-slot:right>
      <div>
        <span v-for="(block, index) in dataBlocks" :key="index">
          {{ block }}<br/>
        </span>
      </div>
    </template>
  </TwoColumnsResizView>
</template>

<script setup>
import TwoColumnsResizView from "@/components/BaseComponents/TwoColumnsResizView.vue"
import {ref} from "vue";
import {getTest} from "../api/getStreamData";

const dataBlocks = ref([]);
const inputdata = ref("");

function fetchStreamData() {
  getTest(inputdata.value,
      (data)=>{
        dataBlocks.value.push(data);
      },
      ()=>{
        // 处理流结束
        console.log('Stream finished.');
      }
  )
}
</script>

<style>
</style>
